
//include file
#include "stdafx.h"
#include "ChessPiece.h"
#include "FileUtility.h"
#include "ChessPiece.h"


/**********************************************************
********
*++
* Method name : ChessPiece::ChessPiece ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
ChessPiece::ChessPiece(void)
{
	isActive = true;
	isSelected = false;

}

/**********************************************************
********
*++
* Method name : ChessPiece::~ChessPiece ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
ChessPiece::~ChessPiece(void)
{
	//BoardCell::~BoardCell();
	selectedImagePointer.Free();
	free(selectedImagePointer);
}

GdiplusImagePtr* ImagePointer = (GdiplusImagePtr*) malloc(sizeof(GdiplusImagePtr)+1);

/**********************************************************
********
*++
* Method name : ChessPiece::SetImage ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::SetImage(std::string fileDir)
{
	//wchar_t* wFileDir = ConvertToWcharT(fileDir);
	wchar_t* wFileDir = FileUtility::GetInstance()->ConvertToWcharT(fileDir);
	ImagePointer.Attach(new Gdiplus::Image(wFileDir));
}


/**********************************************************
********
*++
* Method name : ChessPiece::SetRow ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::SetRow(int inputRow)
{
	if(inputRow>=0)
	{
		boardPosition.y = inputRow;
	}
}

/**********************************************************
********
*++
* Method name : ChessPiece::GetRow ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
int ChessPiece::GetRow()
{
	return boardPosition.y;
}

/**********************************************************
********
*++
* Method name : ChessPiece::SetCollumn ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::SetCollumn(int inputCollumn)
{
	if(inputCollumn>=0)
	{
		boardPosition.x = inputCollumn;
	}
}

/**********************************************************
********
*++
* Method name : ChessPiece::GetCollumn ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
int ChessPiece::GetCollumn()
{
	return boardPosition.x;
}

/**********************************************************
********
*++
* Method name : ChessPiece::SetDeactive ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::SetDeactive()
{
	isActive = FALSE;
}

/**********************************************************
********
*++
* Method name : ChessPiece::SetActive ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::SetActive()
{
	isActive = TRUE;
}

/**********************************************************
********
*++
* Method name : ChessPiece::IsActive ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
bool ChessPiece::IsActive()
{
	return this->isActive;
}

/**********************************************************
********
*++
* Method name : ChessPiece::Update ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::Update()
{
	int cellDistance = ConstValue::padding + ConstValue::cellHeightWidth;
	drawPosition.x = (boardPosition.x) * cellDistance + ConstValue::xBeginDraw ;
	drawPosition.y = (boardPosition.y) * cellDistance + ConstValue::yBeginDraw ;
}

/**********************************************************
********
*++
* Method name : ChessPiece::ChangeSelectedState ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::ChangeSelectedState()
{
	if(isSelected == true)
	{
		isSelected = false;
	}
	else
	{
		isSelected = true;
	}
}

/**********************************************************
********
*++
* Method name : ChessPiece::IsSelected ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
bool ChessPiece::IsSelected()
{
	return isSelected;
}

/**********************************************************
********
*++
* Method name : ChessPiece::SetSelectedImage ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::SetSelectedImage(std::string fileDir)
{
	//wchar_t* wFileDir = ConvertToWcharT(fileDir);
	wchar_t* wFileDir = FileUtility::GetInstance()->ConvertToWcharT(fileDir);
	selectedImagePointer.Attach(new Gdiplus::Image(wFileDir));
}

/**********************************************************
********
*++
* Method name : ChessPiece::Draw ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::Draw(Gdiplus::Graphics &graphics)
{
	if(isSelected == false)
	{
		graphics.DrawImage(ImagePointer, drawPosition.x, drawPosition.y);
	}
	else
	{
		graphics.DrawImage(selectedImagePointer, drawPosition.x, drawPosition.y);
	}
}

/**********************************************************
********
*++
* Method name : ChessPiece::SetRedSide ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::SetRedSide(bool side)
{
	isRedSide = side;
}

/**********************************************************
********
*++
* Method name : ChessPiece::IsRedSide ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
bool ChessPiece::IsRedSide()
{
	return isRedSide;
}

/**********************************************************
********
*++
* Method name : ChessPiece::CanMoveTo ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
bool ChessPiece::CanMoveTo(POINT currPos, POINT newPos)
{
	return true;
}

/**********************************************************
********
*++
* Method name : ChessPiece::WriteLogPieceTurn ()
* Decription  : This method used to
* 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* Parameter : no
* Global available : no
* Return value : no
*               
*--
***********************************************************
********/
void ChessPiece::WriteLogPieceTurn(HWND hListBox,bool isRedSide, POINT currPos, POINT newPos)
{

}
